from math import atan, pi
import numpy as np
import matplotlib.pyplot as plt


plt.subplot(221)
x = np.linspace(-2, 2, 100000)
plt.plot(x, (x**2 - 1)/(x-1), label='removable discontinuity')
plt.annotate("point", (1, 2.0), arrowprops=dict(facecolor='red', shrink=0.05))
plt.yticks(np.arange(-1, 2.5, 0.5))
plt.xlim(-2, 2)
plt.ylim(-1, 2)
plt.legend(loc='center')


plt.subplot(222)
x = np.linspace(-2, 2, 1000)
plt.plot(x, np.abs(x), label='jump discontinuity')
plt.xticks(range(-2, 3, 1))
plt.yticks(np.arange(0, 2.5, 0.5))
plt.xlim(-2, 2)
plt.ylim(0, 2)
plt.legend(loc='upper center')
plt.annotate("point", (0, 0), arrowprops=dict(facecolor='red', shrink=0.05))

plt.subplot(223)
x = [atan(-1)-pi*7, -pi*7+atan(1.1)]
while x[-1] < 20:
    x.append(x[-2]+pi/2)
plt.plot(x, np.tan(x), label='infinite discontinuity')
plt.xlim(-20, 20)
plt.ylim(-1, 1)
plt.yticks(np.linspace(-1.0, 1.0, 5))
plt.legend(loc='upper center')


plt.subplot(224)
x = np.linspace(-0.5, 0.5, 1000)
plt.plot(x, np.sin(1/x), label='discontinuous point of oscillation')
plt.xlim(-0.5, 0.5)
plt.ylim(-1.0, 1)
plt.xticks(np.linspace(-0.4, 0.4, 5))
plt.legend()


plt.show()
